package com.example.photoalbum.service.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.util.PageResult;
import com.example.photoalbum.entity.Photoalbum;
import com.example.photoalbum.mapper.PhotoalbumMapper;
import com.example.photoalbum.service.IPhotoalbumService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
 * <p>
 * 相册信息表 服务实现类
 * </p>
 *
 * @author Jiamingzhen
 * @since 2021-04-23
 */
@Service
public class PhotoalbumServiceImpl extends ServiceImpl<PhotoalbumMapper, Photoalbum> implements IPhotoalbumService {
     @Autowired
    private PhotoalbumMapper photoalbumMapper;
    /**
     * 通过分页查询
     * @param pageNum
     * @return PageResult
     */
    @Override
    public PageResult<Photoalbum> listPage(int pageNum, int pageSize, Photoalbum photoalbum) {
       Page<Photoalbum> page = new Page<Photoalbum>(pageNum, pageSize);
         QueryWrapper<Photoalbum> ew = new QueryWrapper<Photoalbum>();
         IPage iPage = photoalbumMapper.selectPage(page,ew);
          return new PageResult<Photoalbum>(iPage.getRecords(), iPage.getTotal());
    }

    @Override
    public List<Photoalbum> selectList(Photoalbum photoalbum) {
        QueryWrapper<Photoalbum> ew = new QueryWrapper<Photoalbum>();
        return photoalbumMapper.selectList(ew);

     }

    /**
      *  逻辑删除
      */
        @Override
        public Boolean logicDelete(Photoalbum photoalbum){
            photoalbum.setIsDel(1);
            return this.updateById(photoalbum);
        }
}
